package com.joysuch.wwyt.common.bean;

import cn.zlg.common.springmvc.validate.constraints.NotNull;
import com.alibaba.fastjson.JSON;
import com.joysuch.wwyt.common.entity.CommonStaticsReport;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;
import java.util.List;

/**
 * @Author ZhangDong
 * @Date 2020/7/23 14:10
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CommonStaticsReportBean {

    @ApiModelProperty("修改时传值")
    private Long id;

    @ApiModelProperty("标题")
    @NotBlank(message = "标题不能为空")
    private String title;

    @ApiModelProperty("全局标志位: 0 个人; 1 全局")
    @NotNull(message = "全局标志位不能为空")
    private Integer allUserFlag;
    
    @ApiModelProperty("数据来源：0 现有业务; 1 外部链接")
    private Integer dataSources;

    @ApiModelProperty("外部链接URL")
    private String externalLink;

    @ApiModelProperty("图表集")
    private List<CommonStaticsReportDetailBean> chartList;

    public CommonStaticsReportBean(CommonStaticsReport report) {
        this.id = report.getId();
        this.title = report.getTitle();
        this.allUserFlag = report.getAllUserFlag();
        this.chartList = JSON.parseArray(report.getChartList(), CommonStaticsReportDetailBean.class);
        this.dataSources = report.getDataSources();
        this.externalLink = report.getExternalLink();
    }
}
